Home > Java Programming > Variables and Loops > Questions and Answers
01. |
What will be output of following program? class StringLiteral{ public static void main(String[] args){ String str="local\national"; System.out.print(str); } } | |||||||||||
|
02. |
public class TypeConversion { public static void main(String[] args) { double d=2D+2d+2.+2l+2L+2f+2F+2.f+2.D; System.out.println(d); } } | |||||||||||
|
03. |
public class UnaryOperator { public static void main(String[] args) { byte a=-5; int b=-5; int c=~a+(byte)~b; System.out.print(c); } } What will output when you compile and run the above code? | |||||||||||
|
04. |
public class BreakDemo { public static void main(String[] args){ int j=~-3; while(j<7){ System.out.print(j); if(j==3){ j+=2; continue; } j++; } } } What will be output of above program?
| |||||||||||
|
05. |
What will be output of following program? public class Datatype { public static void main(String[] args) { byte b=125; System.out.println(b*2); } } | |||||||||||
|
06. |
public class Identifier { public static void main(String[] args) { double strictfp=5.02; strictfp+=.333; System.out.print(strictfp); } } | |||||||||||
|
07. |
public class TypeConversion { public static void main(String[] args) { float f1=11; float f2=11.f; f2=f1+f2; System.out.println(f2); } } What will output when you compile and run the above code? | |||||||||||
|
08. |
public class Operator { public static void main(String[] args) { byte a=5; int b=10; int c=a>>2+b>>2; System.out.print(c); } } What will output when you compile and run the above code? | |||||||||||
|
09. |
class Mango{ final int a=5; } class Fruit extends Mango { final int a=10; } class DynamicDispatch extends Fruit{ final int a=20; public static void main(String[] args){ Mango m=new DynamicDispatch(); Fruit f=new DynamicDispatch(); System.out.print(m.a|f.a); } } What will be output of above program? | |||||||||||
|
10. | Which is not true java statement? | |||||||||||
|
11. |
public class This { int i; This(){ this.i++; i++; } public static void main(String[] args){ This o=new This(); System.out.print(o.i); } } What will be output of above program? | |||||||||||
|